Conditions | 1 |
Paths | 1 |
Total Lines | 194 |
Code Lines | 136 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | module.exports = function () { |
||
2 | return { |
||
3 | 'reverseGeocodingApi': 'https://nominatim.openstreetmap.org/reverse', |
||
4 | 'maxAge': 14, |
||
5 | 'maxAgeAlert': 3, |
||
6 | 'nodeZoom': 18, |
||
7 | 'labelZoom': 13, |
||
8 | 'clientZoom': 15, |
||
9 | 'fullscreen': true, |
||
10 | 'fullscreenFrame': true, |
||
11 | 'nodeAttr': [ |
||
12 | // value can be a node attribute (1 depth) or a a function in utils/node with prefix show |
||
13 | { |
||
14 | 'name': 'node.status', |
||
15 | 'value': 'Status' |
||
16 | }, |
||
17 | { |
||
18 | 'name': 'node.gateway', |
||
19 | 'value': 'Gateway' |
||
20 | }, |
||
21 | { |
||
22 | 'name': 'node.coordinates', |
||
23 | 'value': 'GeoURI' |
||
24 | }, |
||
25 | // { |
||
26 | // "name": "node.contact", |
||
27 | // "value": "owner" |
||
28 | // }, |
||
29 | |||
30 | // Examples for functions |
||
31 | // { |
||
32 | // // no name will remove first column |
||
33 | // 'value': function (d) { |
||
34 | // var moment = require('moment'); |
||
35 | // var V = require('snabbdom').default; |
||
36 | // return V.h('td', { props: { colSpan: 2 }, style: { background: '#49a' } }, |
||
37 | // _.t('sidebar.nodeOnline') + ' translate, ' + moment(d.firstseen).get('month') + |
||
38 | // ' Month require libs like moment, access config ' + config.siteName); |
||
39 | // } |
||
40 | // }, |
||
41 | // { |
||
42 | // 'name': 'Neighbour first seen', |
||
43 | // 'value': function (d, nodeDict) { |
||
44 | // return nodeDict[d.gateway_nexthop].firstseen.format() + 'access node object'; |
||
45 | // } |
||
46 | // }, |
||
47 | { |
||
48 | 'name': 'node.hardware', |
||
49 | 'value': 'model' |
||
50 | }, |
||
51 | { |
||
52 | 'name': 'node.primaryMac', |
||
53 | 'value': 'mac' |
||
54 | }, |
||
55 | { |
||
56 | 'name': 'node.firmware', |
||
57 | 'value': 'Firmware' |
||
58 | }, |
||
59 | { |
||
60 | 'name': 'node.uptime', |
||
61 | 'value': 'Uptime' |
||
62 | }, |
||
63 | { |
||
64 | 'name': 'node.firstSeen', |
||
65 | 'value': 'FirstSeen' |
||
66 | }, |
||
67 | { |
||
68 | 'name': 'node.systemLoad', |
||
69 | 'value': 'Load' |
||
70 | }, |
||
71 | { |
||
72 | 'name': 'node.ram', |
||
73 | 'value': 'RAM' |
||
74 | }, |
||
75 | { |
||
76 | 'name': 'node.ipAddresses', |
||
77 | 'value': 'IPs' |
||
78 | }, |
||
79 | { |
||
80 | 'name': 'node.update', |
||
81 | 'value': 'Autoupdate' |
||
82 | }, |
||
83 | { |
||
84 | 'name': 'node.domain', |
||
85 | 'value': 'Domain' |
||
86 | }, |
||
87 | { |
||
88 | 'name': 'node.clients', |
||
89 | 'value': 'Clients' |
||
90 | } |
||
91 | ], |
||
92 | 'supportedLocale': [ |
||
93 | 'en', |
||
94 | 'de', |
||
95 | 'cz', |
||
96 | 'fr', |
||
97 | 'tr', |
||
98 | 'ru' |
||
99 | ], |
||
100 | // Color configs |
||
101 | 'icon': { |
||
102 | 'base': { |
||
103 | 'fillOpacity': 0.6, |
||
104 | 'opacity': 0.6, |
||
105 | 'weight': 2, |
||
106 | 'radius': 6, |
||
107 | 'className': 'stroke-first' |
||
108 | }, |
||
109 | 'online': { |
||
110 | 'color': '#1566A9', |
||
111 | 'fillColor': '#1566A9' |
||
112 | }, |
||
113 | 'offline': { |
||
114 | 'color': '#D43E2A', |
||
115 | 'fillColor': '#D43E2A', |
||
116 | 'radius': 3 |
||
117 | }, |
||
118 | 'lost': { |
||
119 | 'color': '#D43E2A', |
||
120 | 'fillColor': '#D43E2A', |
||
121 | 'radius': 4 |
||
122 | }, |
||
123 | 'alert': { |
||
124 | 'color': '#D43E2A', |
||
125 | 'fillColor': '#D43E2A', |
||
126 | 'radius': 5 |
||
127 | }, |
||
128 | 'new': { |
||
129 | 'color': '#1566A9', |
||
130 | 'fillColor': '#93E929' |
||
131 | } |
||
132 | }, |
||
133 | 'client': { |
||
134 | 'wifi24': 'rgba(220, 0, 103, 0.7)', |
||
135 | 'wifi5': 'rgba(10, 156, 146, 0.7)', |
||
136 | 'other': 'rgba(227, 166, 25, 0.7)' |
||
137 | }, |
||
138 | 'map': { |
||
139 | 'labelNewColor': '#459c18', |
||
140 | 'tqFrom': '#F02311', |
||
141 | 'tqTo': '#04C714', |
||
142 | 'highlightNode': { |
||
143 | 'color': '#ad2358', |
||
144 | 'weight': 8, |
||
145 | 'fillOpacity': 1, |
||
146 | 'opacity': 0.4, |
||
147 | 'className': 'stroke-first' |
||
148 | }, |
||
149 | 'highlightLink': { |
||
150 | 'weight': 4, |
||
151 | 'opacity': 1, |
||
152 | 'dashArray': '5, 10' |
||
153 | } |
||
154 | }, |
||
155 | 'forceGraph': { |
||
156 | 'nodeColor': '#fff', |
||
157 | 'nodeOfflineColor': '#D43E2A', |
||
158 | 'highlightColor': 'rgba(255, 255, 255, 0.2)', |
||
159 | 'labelColor': '#fff', |
||
160 | 'tqFrom': '#770038', |
||
161 | 'tqTo': '#dc0067', |
||
162 | 'zoomModifier': 1 |
||
163 | }, |
||
164 | 'locate': { |
||
165 | 'outerCircle': { |
||
166 | 'stroke': false, |
||
167 | 'color': '#4285F4', |
||
168 | 'opacity': 1, |
||
169 | 'fillOpacity': 0.3, |
||
170 | 'clickable': false, |
||
171 | 'radius': 16 |
||
172 | }, |
||
173 | 'innerCircle': { |
||
174 | 'stroke:': true, |
||
175 | 'color': '#ffffff', |
||
176 | 'fillColor': '#4285F4', |
||
177 | 'weight': 1.5, |
||
178 | 'clickable': false, |
||
179 | 'opacity': 1, |
||
180 | 'fillOpacity': 1, |
||
181 | 'radius': 7 |
||
182 | }, |
||
183 | 'accuracyCircle': { |
||
184 | 'stroke': true, |
||
185 | 'color': '#4285F4', |
||
186 | 'weight': 1, |
||
187 | 'clickable': false, |
||
188 | 'opacity': 0.7, |
||
189 | 'fillOpacity': 0.2 |
||
190 | } |
||
191 | }, |
||
192 | 'cacheBreaker': '<!-- inject:cache-breaker -->' |
||
193 | }; |
||
194 | }; |
||
195 |